import request from "@/utils/request";

// 查询全部机构tree
export function queryOrgTree() {
  return request({
    url: "/auth/org/orgTree",
    // headers: {
    //   isToken: false
    // },
    method: "post",
  });
}

// 分页查询列表
export function queryListForPage(size, count) {
  const data = {
    pageSize: size,
    pageCount: count,
  };
  return request({
    url: "/auth/org/querylistForPage",
    method: "get",
    data: data,
  });
}

// 查询详情
export function queryDetail(id) {
  return request({
    url: "/auth/org/detail/" + id,
    method: "post",
  });
}

// 编辑机构
export function modify(form) {
  const data = {
    id: form.id,
    orgId: form.orgId, //机构号
    orgName: form.name, //机构名称
    orgDesc: "", //机构描述
    orgPid: form.orgPid, //父机构ID
    orgLevel: form.orgLevel, //机构级别
    orgAdd: form.orgAdd, //机构地址
    orgCore: form.orgCore, //核心机构号
  };
  return request({
    url: "/auth/org/modify", //'/captchaImage',
    method: "post",
    timeout: 20000,
    data: data,
  });
}

// 添加机构
export function addOrg(form) {
  const data = {
    id: "",
    orgId: form.orgId, //机构号
    orgName: form.name, //机构名称
    orgDesc: "666", //机构描述
    orgPid: form.orgPid, //父机构ID
    orgLevel: form.orgLevel, //机构级别
    orgAdd: form.orgAdd, //机构地址
    orgCore: form.orgCore, //核心机构号
  };
  return request({
    url: "/auth/org/addOrg",
    method: "post",
    data: data,
  });
}

// 删除机构
export function delOrg(id) {
  return request({
    url: "/auth/org/delOrg/" + id,
    method: "delete",
  });
}
